package com.cn.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cn.mapper.UserMapper;
import com.cn.model.User;
import com.cn.service.exception.ErrorCode;
import com.cn.service.exception.ServiceException;

/**
 * 【用户】服务类
 * 
 * @author ZSL
 *
 */
@Service
public class UserService {

	@Autowired
	private UserMapper userMapper;

	/**
	 * 获取用户
	 * 
	 * @param 
	 * @return
	 */
	public User queryUser(String devicenum) {
		
	     if("222".equals(devicenum)){
	 		throw new ServiceException("测试错误",ErrorCode.NO_TOKEN);
	     }
		 return userMapper.queryUser(devicenum);
	}
	
	/**
	 * 添加新用户
	 * 
	 * @param 
	 * @return
	 */
	public void addUser(User user) {
		 userMapper.addUser(user);
	}

	/**
	 * 修改用户
	 * 
	 * @param user
	 */
	public void editUser(User user) {
		 userMapper.editUser(user);
	}
}
